# NMake makefile
# Use MSVC compiler to compile RPC server/client stub as static libs for MinGW
# to link, because MinGW can't correctly compile MIDL generated source.

!include <win32.mak>

INTERFACE = syncup-service
IDL_SRC = $(INTERFACE).idl
SERVER_STUB = $(INTERFACE)_s
CLIENT_STUB = $(INTERFACE)_c
IFACE_HEADER = $(INTERFACE).h

LIBS = $(SERVER_STUB).lib $(CLIENT_STUB).lib
OBJS = $(SERVER_STUB).obj $(CLIENT_STUB).obj alloc.obj
SRCS = $(SERVER_STUB).c $(CLIENT_STUB).c $(IFACE_HEADER)

all: $(LIBS)

$(SERVER_STUB).lib: $(SERVER_STUB).obj alloc.obj
	$(implib) /out:$@ $?

$(SERVER_STUB).obj : $(SERVER_STUB).c $(IFACE_HEADER)
	$(cc) $(cdebug) $(cflags) $(cvarsdll) $*.c

$(CLIENT_STUB).lib: $(CLIENT_STUB).obj alloc.obj
	$(implib) /out:$@ $?

$(CLIENT_STUB).obj : $(CLIENT_STUB).c $(IFACE_HEADER)
	$(cc) $(cdebug) $(cflags) $(cvarsdll) $*.c

alloc.obj: alloc.c $(IFACE_HEADER)
	$(cc) $(cdebug) $(cflags) $(cvarsdll) $*.c

$(IFACE_HEADER) $(SERVER_STUB).c $(CLIENT_STUB).c alloc.c: $(IDL_SRC)
	$(midl) $(IDL_SRC)

clean:
	del $(LIBS) $(OBJS) *.pdb $(SRCS)